package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cheer.dto.OaLearnOrganDto;
import com.cheer.dto.OaRankQueryDTO;
import com.cheer.entity.OaUserEntity;
import com.cheer.vo.OaLearnOrgan;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface OrganVoDao extends BaseMapper<OaLearnOrgan> {

    default IPage<OaLearnOrgan> selectOrganListByPage(OaLearnOrganDto organDto) {

        QueryWrapper<OaLearnOrgan> queryWrapper = new QueryWrapper<>();
        LambdaQueryWrapper<OaLearnOrgan> organVoLambdaQueryWrapper = queryWrapper.lambda()
                .isNotNull(OaLearnOrgan::getOpenId)
                .orderByDesc(OaLearnOrgan::getId);
        if(StringUtils.isNotBlank(organDto.getDept())){
            organVoLambdaQueryWrapper.like(OaLearnOrgan::getDept, organDto.getDept());
        }
        return selectPage(new Page<>(organDto.getPageNum(), organDto.getPageSize()), organVoLambdaQueryWrapper);
    }
}
